﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;


namespace http
{
    public partial class MainPage : PhoneApplicationPage
    {
       
        public MainPage()
        {
            InitializeComponent();
            Loaded += MainPage_Loaded;
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            browser.Navigate(new Uri("http://www.shoppersstop.com/formhandlerservlet?actionName=shoppersBasicSearch&targetNodeLink=/shopBy.jsp&currentNodeLink=/index.jsp&formName=gv&categoryName=010102&searchString=category_010102+brand_proline", UriKind.RelativeOrAbsolute), null, "User-Agent:Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
            this.IsEnabled = false;
        }

        private void browser_ScriptNotify_1(object sender, NotifyEventArgs e)
        {
            //string to search <tbody>
            string fullHTML = e.Value.ToString();
            BackAgent b = new BackAgent();
            b.backagent();
        }

        private void browser_LoadCompleted_1(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            browser.InvokeScript("eval", "this.newfunc_eventHandler=function(e){var fullhtml=document.documentElement.outerHTML.replace(/\\n/g, '').replace(/<br>/g, '<br />').replace(/\\r/g, '').replace(/\\t/g, '');window.external.notify(fullhtml);}");
            browser.InvokeScript("eval", "newfunc_eventHandler()");
            this.IsEnabled = true;
        }
       
       
    }

}